package com.yunfangdata.service.impl;

import com.yunfangdata.domain.SituationOfEducation;
import com.yunfangdata.mapper.SituationOfEducationMapper;
import com.yunfangdata.query.QueryObject;
import com.yunfangdata.service.ISituationOfEducationService;
import com.yunfangdata.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SituationOfEducationServiceImpl implements ISituationOfEducationService {

    @Autowired
    private SituationOfEducationMapper mapper;

    public void save(SituationOfEducation entity) {
        mapper.insert(entity);
    }

    public void delete(Long id) {
        mapper.deleteByPrimaryKey(id);
    }

    public void update(SituationOfEducation entity) {
        mapper.updateByPrimaryKey(entity);
    }

    public SituationOfEducation get(Long id) {
        return mapper.selectByPrimaryKey(id);
    }

    public List<SituationOfEducation> list() {
        return mapper.selectAll();
    }

    public PageResult query(QueryObject qo) {
        int total = mapper.queryForCount(qo);
        if (total == 0){
            return new PageResult();
        }
        List<SituationOfEducation> rows = mapper.queryForList(qo);
        return new PageResult(total,rows);
    }
}
